var express = require("express");
var router = express.Router();
var pomelo = require("pomelo");

//通过id查询活动
router.get("/getActivityById", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.activityRemote.getActivityById(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//查询所有活动
router.get("/getAllActivities", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.activityRemote.getAllActivities(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//根据id修改url
router.get("/updateActivityUrl", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.activityRemote.updateActivityUrl(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//根据id修改Priority
router.get("/updateActivityPriority", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.activityRemote.updateActivityPriority(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//根据id修改活动
router.get("/updateActivity", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.activityRemote.updateActivity(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//插入活动
router.get("/addActivity", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.activityRemote.addActivity(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//通过id删除活动
router.get("/deleteActivityById", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.activityRemote.deleteActivityById(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

module.exports = router;